package com.dsbridge.enrollment;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class EnrollmentServlet
 */
@WebServlet("/EnrollmentServlet")
public class EnrollmentServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	public void init() {
		System.out.println("In the Init Method");
	}

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public EnrollmentServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		PrintWriter pw = response.getWriter();

		System.out.println("In the doGet Method");
		String firstName = request.getParameter("firstname");
		String lastName = request.getParameter("lastname");
		pw.println("Hey ," + firstName + " " + lastName
				+ " Enrolled into Java class Successfully");
		RequestDispatcher rd=request.getRequestDispatcher("EnrolledServlet");
		//rd.forward(request,response);
		//rd.include(request,response);
		response.sendRedirect("http://google.com");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

	}

}
